EXECUTABLE=Tetris
WEXECUTABLE=Tetris.exe

LIBS=\
	-lSDL\
	-lSDL_net\
	-lSDL_ttf\

WLIBS=\
	`/opt/SDL-1.2.13/bin/i586-mingw32msvc-sdl-config --libs`\
	-Dmain=SDL_main\
	-lmingw32\
	-L/opt/SDL-1.2.13/lib\
	
INCLUDES=\
	-Inetwork\
	-IgraphicalElements\
	-IgameStates\
	-Ievents\
	-Iexceptions\

WINCLUDES=\
	-I/opt/SDL-1.2.13/include\
		
SOURCES=\
	Tetris.cpp\
	GameEngine.cpp\
	events/ClientConnectNetworkEvent.cpp\
	events/ClientReadyToPlayNetworkEvent.cpp\
	exceptions/NetworkException.cpp\
	gameStates/ClientMenu.cpp\
	gameStates/GamePlayState.cpp\
	gameStates/GameState.cpp\
	gameStates/LobbyState.cpp\
	gameStates/MainMenu.cpp\
	gameStates/ServerMenu.cpp\
	graphicalElements/Block.cpp\
	graphicalElements/GameArena.cpp\
	graphicalElements/GraphicalComposite.cpp\
	graphicalElements/GraphicalElement.cpp\
	graphicalElements/Menu.cpp\
	graphicalElements/Piece.cpp\
	graphicalElements/Text.cpp\
	graphicalElements/TiledBackground.cpp\
	graphicalElements/Window.cpp\
	network/Client.cpp\
	network/NetworkWrapper.cpp\
	network/Server.cpp\
	network/ServerMessageReceiver.cpp\

CC=g++
WCC=i586-mingw32msvc-g++

CFLAGS= -Wall $(LIBS) -g 
WCFLAGS=`/opt/SDL-1.2.13/bin/i586-mingw32msvc-sdl-config --cflags`-Wall

.PHONY: linux windows windows-compile clean

linux: linux-compile
	cp -r ../resources .
	tar cfv tetris-linux.tar $(EXECUTABLE) resources

linux-compile: $(SOURCES) $(EXECUTABLE)

$(EXECUTABLE): $(SOURCES) 
	$(CC) $(SOURCES) $(CFLAGS) $(INCLUDES) -o $@

windows: windows-compile
	cp ../sdl/dll/*.dll .
	cp -r ../resources .
	tar cfv tetris-windows.tar $(WEXECUTABLE) *.dll resources

windows-compile: $(SOURCES)
	$(WCC) $(WINCLUDES) $(INCLUDES) $(SOURCES) $(WCFLAGS) -o $(WEXECUTABLE) $(WLIBS) $(LIBS)

clean:
	rm -rf *.o $(EXECUTABLE) $(WEXECUTABLE) resources *.dll *.tar
